<form id="search" action="{% url shop.views.product.search %}" method="get">
    <p>
        <label for="category_id">Category</label>
        <select id="category_id" name="category_id">
            {% if category_id %}
                <option value="">All Categories</option>
            {% else %}
                <option selected="selected" value="">All Categories</option>
            {% endif %}
            {% for category in categories %}
                {% if category.id == category_id %}
                    <option value="{{ category.id }}" selected="selected">{{ category.name }}</option>
                {% else %}
                    <option value="{{ category.id }}">{{ category.name }}</option>
                {% endif %}
            {% endfor %}
        </select>
        <label for="q">Search</label>
        <input type="text" id="q" name="q" value="{{ q }}"/>
        <button type="submit">Search</button>
    </p>
</form>
